/***************************************************************************
 创建者: 华磊
 开始时间: 2019.9.20
 copyright: (C) 华友高科
 修改说明: (每次有修改就添加一条，带有 修改人，修改时间，修改描述)
 example (1) 姓名 2019.9.20 类的具体实现代码编写

 ***************************************************************************
 *  @file x.h
 *  功能:
 *
 *
 ***************************************************************************/
#ifndef MainWindowFleetTest_H
#define MainWindowFleetTest_H

#include <QMainWindow>
#include <QTimer>
#include "protocolcodeing.h"
class QTcpSocket;

struct AgvConnectInfo
{
    int agvId;
    QString agvName;
    QString agvIp;
    int port;
};

namespace Ui {
class MainWindowFleetTest;
}

class MainWindowFleetTest : public QMainWindow
{
    Q_OBJECT

public:
    explicit MainWindowFleetTest(AgvConnectInfo agvInfoIn,QWidget *parent = 0);
    ~MainWindowFleetTest();
public:
    AgvConnectInfo getAgvInfo();
    int connectServerForUser();
private slots:
    void timeOut_slot();
    void on_pushButton_clicked();

    void on_pushButton_disconnect_clicked();

    void on_pushButton_send_clicked();

    void on_pushButton_receiveOnce_clicked();

    void on_pushButton_clearText_clicked();

    void on_pushButton_clearAllPath_clicked();

    void on_pushButton_addPath_clicked();

    void on_pushButton_setForkHeight_clicked();

    void on_pushButton_pause_clicked();

    void on_pushButton_stop_clicked();

    void on_pushButton_start_clicked();



    void on_pushButton_clearMessage_clicked();

    void on_pushButton_addMusic_clicked();

    void on_pushButton_addMusic_2_clicked();

    void on_pushButton_setVel_clicked();


    void on_pushButton_setCharge_clicked();

    void on_pushButton_setLift_clicked();

    void on_pushButton_setRoller_clicked();

    void on_pushButton_addPath_complex_clicked();

    void on_pushButton_calculateValue_clicked();

    void on_pushButton_calculateBuma_clicked();

    void on_pushButton_addRobotArmCommand_clicked();

    void on_pushButton_addAutoDrive_clicked();
    void on_pushButton_waitIns_clicked();

    void on_pushButton_2_clicked();

    void on_pushButton_setDo_clicked();

    void on_pushButton_clearErrorAndRunLastStation_clicked();

    void on_pushButton_setBarrier_clicked();

    void on_pushButton_setVehicleBorderOffset_clicked();

    void on_pushButton_shutdown_clicked();

    void on_pushButton_setBorderId_clicked();

signals:
    //获取到一个agv位置信息
    void sig_pub_agv_position(int id,QString name,double x,double y,double theta,
                              QStringList occus,int floor);


private:
    int processBasicInfo(QByteArray tmpBufferIn);
    int processMessageInfo(QByteArray tmpBufferIn);
    int receiveProcess();
    int connectServer(QString ip, int port);
    int disconnectServer();
    int displayAgvBasicInfo();
    int sendAgvCommand(QByteArray agvCommand);
    int receiveSocketBuffer(QByteArray &bufferOut);
    int waitReply(int timeOut);

private:
    Ui::MainWindowFleetTest *ui;
    QTcpSocket *clientSocket;
    QTimer timer;
    ProtocolCodeing *protocolCodeing;
    AgvConnectInfo agvInfo;
};

#endif // MainWindowFleetTest_H
